﻿using DiaoPaiDaYin;
using DXApplicationTangche.UC.ImpUC;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using DXApplicationTangche.UC.门店下单;
using DXApplicationTangche.UC.门店下单.form;
using mendian;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static DXApplicationTangche.UC.门店下单.form.Frm订单一览;

namespace DXApplicationTangche.UC.下单MTO
{
    public partial class FormMTO定制下单 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private String shopId = "18";
        private String pageStart;
        private String pageSize;
        private Enum订单类别 enum订单类别 = Enum订单类别.销售订单;
        private XtraUserControl订单一览 xtraUserControl订单一览 = new XtraUserControl订单一览();
        public delegate void AddTabDataEvents(Form form);//定义委托
        public event AddTabDataEvents addTabDataEvents;//定义事件
        public FormMTO定制下单()
        {
            InitializeComponent();
            this.xtraUserControl订单一览 = new XtraUserControl订单一览(Enum订单类别.销售订单);
            this.xtraUserControl订单一览.Dock = DockStyle.Fill;
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(this.xtraUserControl订单一览);
            this.xtraUserControl订单一览.addTabDataEvents += this.addTab;
        }

        #region 手机号查历史订单
        private void textBox手机号_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (!String.IsNullOrWhiteSpace(textBox手机号.Text))
                {
                    this.load信息(this.textBox手机号.Text.Trim());
                }
            }
        }
        private void load信息(String mobile)
        {
            #region 历史订单
            //String sql历史订单 = "SELECT\n" +
            //    "	s_style_p.SYS_STYLE_ID,\n" +
            //    "	o_order_p.ORDER_ID AS `ORDER_ID`,\n" +
            //    "	o_order_p.ORDER_NO AS `订单号`,\n" +
            //    "	o_order_p.CUSTOM_NAME AS `订单姓名`,\n" +
            //    "	s_style_p.STYLE_NAME_CN AS `款式名称`,\n" +
            //    "	o_order_p.REMARKS AS `备注`,\n" +
            //    "	o_order_p.CREATE_DATE AS `下单时间` \n" +
            //    "FROM\n" +
            //    "	o_order_p\n" +
            //    "	LEFT JOIN s_style_p ON o_order_p.STYLE_ID = s_style_p.SYS_STYLE_ID \n" +
            //    "WHERE\n" +
            //    "	o_order_p.CUSTOMER_ID IN ( SELECT CUSTOMER_ID FROM a_customer_address_p WHERE a_customer_address_p.MOBILE = '" + mobile + "' )";
            //this.gridControl历史订单.DataSource = SQLmtm.GetDataTable(sql历史订单);
            #endregion
            this.gridControl历史订单.DataSource = 订单预览新Service.getHistoryOrderCommitByMobile(mobile);
        }
        #endregion
        private void addTab(Form form)
        {
            this.addTabDataEvents(form);
        }
    }
}
